package com.stk.triplecity;

import com.stk.triplecity.R;
import com.stk.triplecity.Sounds;

import android.content.Context;
import android.media.AudioManager;
import android.media.SoundPool;

public class Sounds {
	
	private SoundPool sounds;
	private int join;
	private int put;
	private int delete;
	private int open;
	private int storm;
	private static Sounds instance = null;
	
	public static Sounds getInstance(Context c){
		if (instance==null){
			instance=new Sounds(c);
		}
		return instance;
	}
	
	public Sounds(Context c){
		loadSound(c);
	}
	
	public void loadSound(Context context) {
	    sounds = new SoundPool(5, AudioManager.STREAM_MUSIC, 0);

	    join = sounds.load(context, R.raw.join, 1);
	    put = sounds.load(context, R.raw.put, 1);
	    delete = sounds.load(context, R.raw.delete, 1);
	    open = sounds.load(context, R.raw.open, 1);
	    storm = sounds.load(context,  R.raw.storm, 1);
	}
	
	public void playJoin(boolean v) {
		if (v){
			sounds.play(join, 1, 1, 1, 0, 1);
		}	    
	}
	
	public void playPut(boolean v) {
		if (v){
			sounds.play(put, 1, 1, 1, 0, 1);
		}
	}
	
	public void playDelete(boolean v) {
		if (v){
			sounds.play(delete, 1, 1, 1, 0, 1);
		}
	}
	
	public void playOpen(boolean v) {
		if (v){
			sounds.play(open, 1, 1, 1, 0, 1);
		}
	}

	public void playStorm(boolean v) {
		if (v){
			sounds.play(storm, 1, 1, 1, 0, 1);
		}		
	}

}
